$(document).ready(function () {
    // 移动端下拉菜单栏
    var nw = $('.navigation-wrapper');

    // 定义菜单关闭事件
    function bounceOutUp() {
        nw.on(function () {
            nw.toggleClass('visible animated bounceOutUp');
        });
        nw.toggleClass('animated bounceInDown animated bounceOutUp');
    }

    // 根据菜单状态定义单击的操作
    $('.btn-mobile-menu').click(function () {
        if (nw.css('display') === "block") {
            bounceOutUp();
        } else {
            nw.toggleClass('visible animated bounceInDown');
        }
        $('.btn-mobile-menu_icon').toggleClass('list arrow circle down animated fadeIn');
    });
    // 点击下拉菜单以外的其他标签区域收起菜单生效
    $(".panel-main").on('click', ':not(.mobile,.btn-mobile-menu,.navigation-wrapper)', function () {
        if (nw.hasClass("bounceInDown")) {
            bounceOutUp();
            $('.btn-mobile-menu_icon').toggleClass('list arrow circle down animated fadeIn');
        }
    });
    // 阻止冒泡事件执行
    nw.click(function (event) {
        event.stopPropagation();
    });


    var a_idx = 0;
	$("body").click(function (e) {
		var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善");
		var $i = $("<span/>").text(a[a_idx]);
		a_idx = (a_idx + 1) % a.length;
		var x = e.pageX,
			y = e.pageY;
		$i.css({
			"z-index": 100000000,
			"top": y - 30,
			"left": x,
			"position": "absolute",
			"font-weight": "bold",
			"color": color()
		});
		$("body").append($i);
		$i.animate({
			"top": y - 180,
			"opacity": 0.8
		}, 2000, function () {
			$i.remove();
		});
	});
	
	function color() {
		return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
	}
	

    // 随机背景图片
    var bgNum = 10; // 定义随机数范围 1-10 和图片数量保持一致
    var randomNum = Math.round(Math.random() * bgNum) + 1;
    var imgUrl = './Noisky_files/img/background-image/bg-' + randomNum + '.jpg';
    $('#bg-img').html("<header class='panel-cover' style='background-image: url(" + imgUrl + ")'></header>");
});